/********************************************************************************
 * Copyright (c)2016-2020, ShenZhen WanJiaAn Technology CO.,LTD.
 * All Rights Reserved.
 *
 * File Name     : DevConfig.h
 * Author        : joki.zhu
 * Date          : 2020-02-23
 *
 * Record        :
 * 1.Date        : 2020-02-23
 *   Author      : joki.zhu
 *   Modification: Created file
 ********************************************************************************/

#ifndef __DEVCONFIG_H__
#define __DEVCONFIG_H__

#ifdef __cplusplus
#if __cplusplus
extern "C"{
#endif
#endif /* __cplusplus */

//#define TAG_FILE_PATH        "tag1.bin"

typedef struct {
	char model[16]; // 产品类型 
	char chip[16]; // 芯片型号
	char client[16]; //客户类型
	char hardVer[32];
	char softVer[32];
	char mcuVer[32];
	char mcuCrc[12];
	char packTime[16]; //软件包时间
	char uuid[32];
	char cmei[32];
	char secretKey[76]; //秘钥
	char alexaid[32];
}FACTORY_CONFIG;

typedef struct {
	int width;
	int height;
	int bitrate;
	char bFlip;
	char irNightMode; //0:关闭 1:开启 2:自动
}VIDEO_CONFIG;

typedef struct {
	signed char bellVol;       /**< 门铃播放音量 */
	signed char alarmVol;      /**< 告警播放音量 */
	signed char netcfgVol;     /**< 配网播放音量 */
	signed char talkbackVol;   /**< 对讲播放音量 */
}PLAY_VOLUME_CONFIG;

typedef struct {
//	int playVol;
	PLAY_VOLUME_CONFIG playvol;
}AUDIO_CONFIG;

typedef struct {
	char ssid[32];
	char password[64];
	char encrypt[32];
	char bSleepMode;
	char dns1[16];
	char dns2[16];
}WIFI_CONFIG;

typedef struct {
    char logLevel;
	char bLed; // LED开关
	char bPir; // PIR开关
	char pirLevel; // PIR灵敏度等级
	char bAlarm; // 报警开关
	char bBell; // 门铃开关
}DEVICE_CONFIG;

typedef struct {
	char bEnable;
	unsigned int startTime;
	unsigned int endTime;
	int zoneSec;
}TIMEZONE_CONFIG;

typedef struct {
	char downUrl[256];
	char md5[36];
	int pktSize;
	int state;   //0:升级完成 1:升级开始
	int retryCnt;
}UPGRADE_CONFIG;

typedef struct {
	FACTORY_CONFIG factory;
	VIDEO_CONFIG video;
	AUDIO_CONFIG audio;
	WIFI_CONFIG wifi;
	DEVICE_CONFIG device;
	TIMEZONE_CONFIG timezone;
	UPGRADE_CONFIG upgrade;
}APP_CONFIG;

int DevConfigInit(void);
int DevConfigDeinit(void);
APP_CONFIG *DevConfigGetHandle(void);
int DevConfigSave(void);
int DevConfigCommit(void);

int DevConfigGetUuid(char *pUuid, int maxLen);
int DevConfigSetUuid(char *pUuid);

int DevConfigGetCmei(char *pCmei, int maxLen);
int DevConfigSetCmei(char *pCmei);

int DevConfigGetSecretKey(char *pSecrteKey, int maxLen);
int DevConfigSetSecretKey(char *pSecrteKey);

int DevConfigGetAlexaid(char *pAlexaid, int maxLen);
int DevConfigSetAlexaid(char *pAlexaid);

int DevConfigGetHardVersion(char *pVer, int maxLen);
int DevConfigSetHardVersion(char *pVer);

int DevConfigGetSoftVersion(char *pVer, int maxLen);
int DevConfigSetSoftVersion(char *pVer);

int DevConfigGetMcuVersion(char *pVer, int maxLen);
int DevConfigSetMcuVersion(char *pVer);

int DevConfigGetMcuCrc(char *pCrc, int maxLen);
int DevConfigSetMcuCrc(char *pCrc);

int DevConfigGetPackTime(char *packTime, int maxLen);
int DevConfigSetPackTime(char *packTime);

int DevConfigGetIrNightMode(int *pMode);
int DevConfigSetIrNightMode(int mode);

int DevConfigGetVideoResolution(int *pWidth, int *pHeight, int *pBitrate);
int DevConfigSetVideoResolution(int width, int height, int bitrate);

int DevConfigGetPlayVolume(PLAY_VOLUME_CONFIG *pstPlayVol);
int DevConfigSetPlayVolume(PLAY_VOLUME_CONFIG stPlayVol);

int DevConfigGetWifi(char *ssid, char *password, char *encrypt);
int DevConfigSetWifi(char *ssid, char *password, char *encrypt);

int DevConfigGetWifiSleepMode(char *pMode);
int DevConfigSetWifiSleepMode(char mode);

int DevConfigGetWifiDns(char *dns1, char *dns2);
int DevConfigSetWifiDns(char *dns1, char *dns2);

int DevConfigGetLogLevel(int *pLogLevel);
int DevConfigSetLogLevel(int logLevel);

int DevConfigGetPirSwitch(char *pPirSwitch);
int DevConfigSetPirSwitch(char pirSwitch);
int DevConfigGetPirLevel(char *pPirLevel);
int DevConfigSetPirLevel(char pirLevel);

int DevConfigGetAlarmSwitch(char *pAlarmSwitch);
int DevConfigSetAlarmSwitch(char alarmSwitch);

int DevConfigGetTimeZone(TIMEZONE_CONFIG *pstTimeZone);
int DevConfigSetTimeZone(TIMEZONE_CONFIG stTimeZone);

int DevConfigGetUpgradeInfo(UPGRADE_CONFIG *pstUpgradeInfo);
int DevConfigSetUpgradeInfo(UPGRADE_CONFIG stUpgradeInfo);

int DevConfigGetUpgradeState(int *pUpgradeState);
int DevConfigSetUpgradeState(int upgradeState);

int DevConfigGetUpgradeRetryCnt(int *pRetryCnt);
int DevConfigSetUpgradeRetryCnt(int retryCnt);

int DevConfigSetDefault(void);

int cmd_devtag(int argc, const char *argv[]);

#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */


#endif /* __DEVCONFIG_H__ */
